package com.cabd.service.impl;

import java.sql.SQLException;

import com.cabd.dao.UserDao;
import com.cabd.dao.impl.UserDaoImpl;
import com.cabd.domain.User;
import com.cabd.service.UserService;

public class UserServiceImpl implements UserService{
	@Override
	public void register(User user) {
		UserDao userDao = new UserDaoImpl();
		try {
			userDao.add(user);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	public User login(User userComeWeb) {
		UserDao userDao = new UserDaoImpl();
		User userComeDataBase = null;
		try {
			userComeDataBase = userDao.findUserByUserIdAndPassword(userComeWeb);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return userComeDataBase;	
	}

	@Override
	public User checkId(String str) {
		UserDao userDao = new UserDaoImpl();
		User userCommeDataBase = null;
		try {
			userCommeDataBase = userDao.findUserById(str);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return userCommeDataBase;
	}
}
